


#ifndef PF_LAYER_H
#define PF_LAYER_H

#ifdef __hpux
#include <sys/_size_t.h>
#endif

#include <iostream>
#include <QString>

#include "pf_pen.h"
#include "lx_Export.h"


/**
 * Holds the data that defines a layer.
 */
class LX_EXPORT PF_LayerAttribute {
public:
    PF_LayerAttribute() {}

    PF_LayerAttribute(const QString& name,
	             const PF_Pen& pen,
				 bool frozen,
				 bool locked) {
		this->name = name;
		this->pen = pen;
		this->frozen = frozen;
		this->locked = locked;
    }

    //! Layer name
    QString name;

    //! default pen for this layer
    PF_Pen pen;

	//! Frozen flag
	bool frozen;
	
	//! Locked flag
	bool locked;

	bool converted;
};



/**
 * Class for representing a layer
 *

 */
class LX_EXPORT PF_Layer {
public:
    explicit PF_Layer(const QString& name);
    //PF_Layer(const char* name);
	
    PF_Layer* clone() {
		return new PF_Layer(*this);
	}

    /** sets a new name for this layer. */
    void setName(const QString& name) {
        data.name = name;
    }

    /** @return the name of this layer. */
    QString getName() const {
        return data.name;
    }

    /** sets the default pen for this layer. */
    void setPen(const PF_Pen& pen) {
        data.pen = pen;
    }

    /** @return default pen for this layer. */
    PF_Pen getPen() const {
        return data.pen;
    }

    /**
     * @retval true if this layer is frozen (invisible)
     * @retval false if this layer isn't frozen (visible)
     */
    bool isFrozen() const {
        return data.frozen;
		//getFlag(LX_Define::FlagFrozen);
    }

	/**
	 * @retval true the layer has been converted already
	 * @retval false the layer still needs to be converted
	 */
    bool isConverted() const {
		return data.converted;
	}

	/**
	 * Sets the converted flag
	 */
	void setConverted(bool c) {
		data.converted = c;
	}

    /**
     * Toggles the visibility of this layer.
     * Freezes the layer if it's not frozen, thaws the layer otherwise
     */
    void toggle() {
        //toggleFlag(LX_Define::FlagFrozen);
		data.frozen = !data.frozen;
    }

    /**
     * (De-)freezes this layer.
     *
     * @param freeze true: freeze, false: defreeze
     */
    void freeze(bool freeze) {
		data.frozen = freeze;
        /*if (freeze) {
            setFlag(LX_Define::FlagFrozen);
        } else {
            delFlag(LX_Define::FlagFrozen);
        }*/
    }

    /**
     * Toggles the lock of this layer.
     */
    void toggleLock() {
        //toggleFlag(LX_Define::FlagFrozen);
		data.locked = !data.locked;
    }
	
	/**
     * Locks/Unlocks this layer.
     *
     * @param l true: lock, false: unlock
     */
	void lock(bool l) {
		data.locked = l;
	}

	/**
	 * return the LOCK state of the Layer
     */
	bool isLocked() {
		return data.locked;
	}

    /**
     * Copies all attributes (pen) and the name of the layer.
     */
	/*
    PF_Layer& operator = (const PF_Layer& l) {
        setName(l.getName());
        setPen(l.getPen());
		setFrozen(l.isFrozen());
        return *this;
    }
	*/

    friend std::ostream& operator << (std::ostream& os, const PF_Layer& l);

    //friend class PF_LayerList;

private:
	//! Layer data
	PF_LayerAttribute data;

};

#endif
